package org.database.generator.code.utils;

import java.io.*;

/**
 * @author liangsu
 * @version v1.0
 * @Description
 * @Date 2019/8/28 9:52
 * @since
 */
public class IOUtils {

    public static void wirteStringToFile(String content, File file, boolean writeIfExists){
        if(!file.exists() || writeIfExists){
            wirteStringToFile(content, file);
        }
    }

    public static void wirteStringToFile(String content, File file){
        try {
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(content.getBytes("utf-8"));
            fos.flush();
            fos.close();
            System.out.println("生成文件：" + file.getPath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
